package main

import  (
	"github.com/gin-gonic/gin"
	"fmt"
	"net/http"
)

func main() {
	rotuer := gin.Default()
	rotuer.GET("/data",func(c *gin.Context){
		name := c.DefaultQuery("name","默认")
		name1 := c.Query("name1")
		//  c.String(http.StatusOK,"name default %s ,name1 is %s",name,name1);
	    c.JSON(http.StatusOK,gin.H{
			"name":name,
			"name1":name1,
		})
	})

	rotuer.POST("/postdata",func(c *gin.Context){
		name := c.DefaultPostForm("name","你是")
		name1 := c.PostForm("name1")
		// c.String(http.StatusOK,"post default %s ,name1 is %s",name,name1)
		  c.JSON(http.StatusOK,gin.H{
			"name":name,
			"name1":name1,
		})
	})


	rotuer.POST("/todata",func(c *gin.Context){
		name := c.DefaultQuery("name","nishi")
		value := c.PostForm("title")
		//   c.String(http.StatusOK,"get name is default %s , value %s ",name,value)
		  fmt.Printf("get name is default %s , value %s ",name,value)
	})

	rotuer.Run();

}